<template>
  <div>
    <el-container>
      <!-- 头部 -->
      <el-header class="d-flex justify-content-between">
        <div class="_header d-flex justify-content-between col-md-6">
          <div>网易云音乐</div>
          <div class="d-flex">
            <div>
              <el-button
                icon="el-icon-arrow-left"
                circle
                @click="router_left"
              ></el-button>
              <el-button
                icon="el-icon-arrow-right"
                circle
                @click="router_right"
              ></el-button>
            </div>
            <div class="seek d-flex">
              <input type="text" v-model="input" placeholder="请输入内容" />
            </div>
          </div>
          <el-button icon="el-icon-microphone" circle></el-button>
        </div>
        <div class="d-flex statusbar">
          <el-avatar icon="el-icon-user-solid"></el-avatar>
          <span>{{ username }}</span>
        </div>
      </el-header>
      <el-container>
        <!-- 侧边栏 -->
        <el-aside width="200px">
          <el-menu>
            <el-menu-item
              v-for="(item, index) in navbar"
              :key="index"
              :disabled="item.disabled"
              @click="navchange(index)"
            >
              <router-link :to="{ name: item.name }">
                <i :class="item.ys"></i>

                <span :style="n == index ? { color: 'royalblue' } : ''">{{
                  item.title
                }}</span>
              </router-link>
            </el-menu-item>
          </el-menu>
        </el-aside>

        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
      <!-- 播放器 -->
      <!-- <Music /> -->
      <Musicpaly/>
      <!-- 播放器 -->
    </el-container>
  </div>
</template>

<script>
// import Music from "../components/music.vue";
import Musicpaly from "../components/musicpaly.vue";
let navbar = [
  { title: "发现音乐", name: "findmusic" },
  { title: "博客", name: "findmusic" },
  { title: "视频", name: "findmusic" },
  { title: "朋友", name: "findmusic" },
  { title: "直播", name: "findmusic" },
  { title: "私人FM", name: "findmusic" },
  { title: "我的音乐", disabled: true },
  { title: "本地与下载", ys: "el-icon-download" },
  { title: "最新播放", ys: "el-icon-service" },
  { title: "创建歌单", disabled: true },
];
export default {
  name: "Home",
  data() {
    return {
      n: "",
      input: "",
      navbar,
    };
  },
  components: {
    // Music,
    Musicpaly
  },
  computed: {
    username() {
      if (localStorage.getItem("data")) {
        var Aname = JSON.parse(localStorage.getItem("data"))[1];
      } else {
        Aname = "未登入";
      }
      return Aname;
    },
  },
  methods: {
    navchange(index) {
      this.n = index;
    },
    router_left() {
      this.$router.go(-1);

      // console.log(1);
    },
    router_right() {
      this.$router.go(1);
      //  console.log(2);
    },
  },
  mounted(){
    if (!localStorage.getItem("data")) {
      this.$router.push("/login")
    }
 
  }
};
</script>

<style lang="scss">
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  align-items: center;
  ._header {
    min-width: 500px;
    align-items: center;
  }
}
.el-header {
  background-color: #ec4141;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  // text-align: center;
}
.el-aside::-webkit-scrollbar {
  display: none;
}
.el-main::-webkit-scrollbar {
  display: none; /* Chrome Safari */
}
.el-main {
  padding: 0px !important;
  height: calc(100vh - 120px);
  background-color: #e9eef3;
  color: #333;
}
.seek {
  align-items: center;
  input {
    padding: 5px 5px 5px 15px;
    margin-left: 10px;
    border-radius: 20px !important;
    border: none;
  }
}
.statusbar {
  span {
    margin-left: 5px;
  }
  align-items: center;
}
.el-menu-item {
  a {
    display: inline-block;
    width: 100%;
  }
}
</style>
